﻿/*从数组中删除指定的对象,返回删除是否成功*/
Array.prototype.remove = function (o) { var i = this.indexOf(o); if (i >= 0) { this.splice(i, 1); return true; } else { return false; } };
toastr.options = {
    "closeButton": false,
    "debug": false,
    "positionClass": "toast-bottom-right",
    "onclick": null,
    "showDuration": "300",
    "hideDuration": "1000",
    "timeOut": "3000",
    "extendedTimeOut": "1000",
    "showEasing": "swing",
    "hideEa sing": "linear",
    "showMethod": "fadeIn",
    "hideMethod": "fadeOut"
}

var EJ = {
    pageSizes: [10, 20, 40, 60, 80, 100],   //可选的每页显示数量
    showMsg: function (msg) {               //显示信息
        swal('提示', msg, 'info');
    },
    showSuccess: function (msg) {           //显示操作成功
        swal('成功', msg, 'success');
    },
    showError: function (msg) {             //显示错误信息
        swal('错误', msg, 'error');
    },
    confimWarn: function (msg, fn) {        //警告询问
        swal({
            title: '警告',
            text: msg,
            type: 'warning',
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, fn);
    },
    confimInfo: function (msg, fn) {         //提示询问
        swal({
            title: '提示',
            text: msg,
            type: 'info',
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            closeOnConfirm: false
        }, fn);
    },
    showRemoteError: function (data, status, headers, config) {         //显示远程服务器错误!
        swal('远程服务器错误', status, 'error');
    },
    toastrInfo: function (msg) { toastr['info'](msg, '提示'); },
    toastrWarning: function (msg) { toastr['warning'](msg, '警告'); },
    toastrSuccess: function (msg) { toastr['success'](msg, '成功'); },
    toastrError: function (msg) { toastr['error'](msg, '错误'); },
    getPageIndexes: function(cIndex, tPages, iCount) {    /*求出当前所处的页索引号段(当前页,总页,总显示索引数)*/
        var begin = 1, end = tPages;
        if (tPages > iCount) {
            var part = parseInt(iCount / 2);
            if (cIndex <= part) {
                begin = 1;
                end = iCount;
            } else if (cIndex >= (tPages - part)) {
                end = tPages;
                begin = (tPages - iCount) + 1;
            } else {
                begin = cIndex - part;
                end = (begin + iCount) - 1;
            }
        }
        var arr = [];
        for (var i = begin; i <= end; i++) { arr.push(i); }
        return arr;
    }
}